import { ref } from 'vue';
import { HooksDemoActionType } from './hooksdemo';

export const useHooksDemo = (
  props: any,
): [(instance: HooksDemoActionType) => void, HooksDemoActionType] => {
  const instanceRef = ref<any>(null);
  const register = (instance: any) => {
    instanceRef.value = instance;
    instanceRef.value?.setProps(props);
  };
  const methods = {
    setProps(mProps: any) {
      instanceRef.value?.setProps(mProps);
    },
    getProps() {
      return instanceRef.value?.getProps();
    },
  } as HooksDemoActionType;
  return [register, methods];
};
